package com.framework.bas.log;

import java.net.URL;

import org.apache.log4j.xml.DOMConfigurator;
import org.springframework.beans.factory.InitializingBean;

public class BasLogManager implements InitializingBean {
	public static final String BEAN_ID="apiBasLogManager";
	
	private String logConfigPath;

	public String getLogConfigPath() {
		return logConfigPath;
	}

	public void setLogConfigPath(String logConfigPath) {
		this.logConfigPath = logConfigPath;
	}

	public void afterPropertiesSet() throws Exception {
		System.setProperty("org.apache.commons.logging.LogFactory", "org.apache.commons.logging.impl.LogFactoryImpl");
        System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.Log4JLogger");
        URL path = Thread.currentThread().getContextClassLoader().getResource(logConfigPath);
        System.setProperty("log4j.configuration", path.getFile());
        System.setProperty("log4j.properties", path.getFile());
        //XML文件配置日志方式
    	DOMConfigurator.configure(path.getPath().replaceAll("%20", " "));
    	//PropertyConfigurator.configure(path.getFile());
	}
}
